package com.my.zidingyikongjian.view.one;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.view.View;

/**
 * 项目名称：画矩形
 * 创建人：
 * 创建时间：2018/7/9 16:16
 */

public class RectView extends View {

    public RectView(Context context) {
        super(context);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        Paint paint = new Paint();
        paint.setStrokeWidth(15);// 画笔宽度
        paint.setStyle(Paint.Style.FILL); // 样式
        paint.setColor(Color.GREEN);

        // 直接画
        canvas.drawRect(10, 10, 100, 100, paint);

        RectF rectF = new RectF(120, 10, 210, 100);
        canvas.drawRect(rectF, paint);// 使用RectF构建

        android.graphics.Rect rect = new android.graphics.Rect(230, 10, 320, 100);
        canvas.drawRect(rect, paint);
    }
}
